import Foundation

protocol MPConvertibleUrl {}
extension NSURL: MPConvertibleUrl {}
extension URL: MPConvertibleUrl {}

func mp_url(_ value: Any) -> MPConvertibleUrl? {
    guard let str = value as? String, str.contains("://")
        else { return value as? URL }
    return str.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed).flatMap { URL(string: $0) }
}
